/**
* <p>Title: Main</p>
* <p>Description: CS343 Project</p>
* @author Derek Meisner
* @author Conor Lauer
* @author Derek Thompson
* @email meis0056@umn.edu
* @email conor.lauer@my.uwrf.edu
* @email derek.thompson-1@my.uwrf.edu
* @date 11/14/2012
* @team Derek, Conor, Derek
*/

package golfScore;

import javax.swing.*;

public class Main {
	
	public static void main(String[] args) {
		
		//Provide instructions for user
		String ms = "Instructions\n\n" +
				"1) Select a course to play\n" +
				"2) Select a user that will be playing golf\n" +
				"3) Use drag and drop on --> & <-- to go to the next or previous hole\n" +
				"4) Or use next and back buttons below arrows\n" +
				"5) Use up down buttons to record your score\n" +
				"6) Use the save button to save scores into a user XML file.\n\n\n";
		JOptionPane.showMessageDialog(null, ms, "Golf Program Details", JOptionPane.INFORMATION_MESSAGE);
		
		//File paths
		final String DIRECTORY = "src/golfScore/";
		final String COURSEFILENAME = "coursesFile.xml";
		final String USERFILENAME = "userFile.xml";
		final String COMPLETE_COURSE_NAME = DIRECTORY + COURSEFILENAME;
		final String COMPLETE_USER_NAME = DIRECTORY + USERFILENAME;
		
		//Setup import
		XML_Interactions newImport = new XML_Interactions(COMPLETE_COURSE_NAME, COMPLETE_USER_NAME);
		
		//Get courses and user from XML files
		Object[] coursesAvailable = newImport.getCourseNames();
		Object[] usersAvailable = newImport.getUsers();
		System.out.println( coursesAvailable[0]);
		
		//Allow user to select course
		String courseSelected = (String) JOptionPane.showInputDialog(new JFrame(), "Please choose a course...", "Course Selection", JOptionPane.PLAIN_MESSAGE, null, coursesAvailable, "Test1");
		if (courseSelected != null){
			
			//Allow user to select user
			String userSelected = (String) JOptionPane.showInputDialog(new JFrame(), "Please choose a user...", "User Selection", JOptionPane.PLAIN_MESSAGE, null, usersAvailable, "Test1");
			
			if (userSelected != null){
				
				//After course and user are verified create course and user
				Course course = newImport.getCourse(courseSelected);
				User user = newImport.getUser(userSelected);
				
				//Print out course name and holes for fun
				System.out.println(courseSelected);
				for (Hole i : course.getHoles())
					System.out.println(i.getHoleVal());
				
				//Create GUI and set visible
				HoleGUI newRound = new HoleGUI(courseSelected, course, user, newImport);
				newRound.setVisible(true);
			}
		}
	}
}